﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AutoUpdater
{
    public class VersionInspector
    {

        private VersionInspector() {

        }

        public static Boolean RequireUpdate(string version) {

            try {
                GetServerVersion();
                var currentVersion = new Version(version);
                var serverVersion = new Version(PackageInfo.Version);
                return serverVersion > currentVersion;
            } catch {
                return false;
            }
        }

        private static void GetServerVersion() {
            var client = new AutoUpdaterService.AutoUpdaterServicesSoapClient();
            var json = client.GetPackageInfo();
            PackageInfo = PackageInfo.LoadFrom(json);
        }

        public static PackageInfo PackageInfo { get; set; }
    }
}
